#!/bin/bash
read -t 30 -p 'enter num 1 :' num1
read -t 30 -p 'enter num 2 :' num2
read -t 30 -p 'enter operator  : ' oper

echo $num1
echo $oper
echo $num2

if [ -z "$num1" -o -z "$num2" -o -z "$oper" ];then
    echo 'zero in args!'
    exit 10
fi

n1=$(echo $num1 | sed 's/[0-9]//g' )
n2=$(echo $num2 | sed 's/[0-9]//g' )

if [ -n "$n1" -o -n "$n2" ];then
   echo "not prue number"
   exit 11
fi

if [ "$oper" == "+" ];then
   echo $(($num1 +$num2))
elif [ "$oper" == "-" ];then
   echo $(( $num1 - $num2))
elif [ "$oper" == "*" ];then
   echo $(( $num1*$num2))
elif [ "$oper" == "/" ];then
   echo $(($num1/$num2))
else
  echo "illegal operator"
fi


#判断输入是否为纯数字
#!/bin/bash
read -t 30 -p "please enter a :" a
b=$(echo $a | sed 's/[0-9]//g')
echo $b